import { sort } from '@/utils/mergeSort';
import { PageContainer } from '@ant-design/pro-components';
import { cloneDeep } from 'lodash';
import React, { useEffect } from 'react';
import * as _ from 'lodash'
import { selectionSort } from '@/utils/selectionSort';
const Index1: React.FC = () => {

    useEffect(() => {
        // 归并合并

        const arr = new Array(100000).fill(0).map(() => Math.floor(Math.random() * 10));
        const testArr = cloneDeep(arr);
        const testArr2 = cloneDeep(arr);

        console.log(
            'testArr2',
            testFunc(() => {
                testArr2.sort((a, b) => a - b)
            })
        )

        console.log(
            'selectionSort',
            testFunc(() => {
                selectionSort(testArr)
            })
        )

        console.log(
            'mergeSort',
            testFunc(() => {
                sort(arr, 0, arr.length - 1)
            })
        )

    }, [])

    const testFunc = (callback: () => void) => {

        let startTime = new Date().getTime();
        callback?.();
        let endTime = new Date().getTime();

        return endTime - startTime;
    }

    return (
        <PageContainer ghost>

        </PageContainer>
    )
}

export default Index1;